#!/usr/bin/env python2
# -*- coding: utf-8 -*-

import sys
import logging
import web
import platform

import config

from log import init_logger

logger = logging.getLogger(config.webpy_app_log)

urls = (
    '/(.*)', 'index'
)


class index:
    def GET(self, name):
        if not name:
            name = 'world'
            pass
        logger.info(name)
        return 'hello,' + name + '!'

    pass


if __name__ == "__main__":
    init_logger(logger)
    app = web.application(urls, globals())
    # 通过判断系统类型是Linux就是使用fcgi或fastcgi启动
    if 'Linux' == platform.system():
        web.wsgi.runwsgi = lambda func, addr=None: web.wsgi.runfcgi(func, addr)
        pass
    app.run()
    pass
